package com.aspose.cells;

import java.util.ArrayList;

abstract class zamb {
   private static float j = com.aspose.cells.a.d.zfq.a();
   private static float k = 96.0F;
   ArrayList a;
   float b = 0.0F;
   float c = 0.0F;
   float d = 0.0F;
   float e = 0.0F;
   float f = 0.0F;
   protected com.aspose.cells.b.a.b.zt g;
   float h = 0.0F;
   private float l;
   private double[] m;
   boolean i = false;

   protected zamb(ArrayList var1, boolean var2, boolean[] var3, float var4, float var5, int var6, zga var7, float var8, double[] var9) throws Exception {
      this.m = var9;
      this.l = var8;
      Font var10 = var7.c().getFont();
      this.a = new ArrayList();
      byte var11 = -1;
      byte var12 = -1;
      this.g = new com.aspose.cells.b.a.b.zt();
      float var13 = 0.0F;
      boolean var14 = var7.c().getRotationAngle() == 255;
      int[] var15 = new int[]{var11};
      int[] var16 = new int[]{var12};
      com.aspose.cells.b.a.b.zt[] var17 = new com.aspose.cells.b.a.b.zt[]{this.g};
      float[] var18 = new float[]{var13};
      boolean var19 = this.a(var10, var4, var1, var2, var3, var5, var7.c().getRotationAngle(), var14, var15, var16, var17, var18);
      int var24 = var15[0];
      int var25 = var16[0];
      this.g = var17[0];
      var13 = var18[0];
      float var20 = 0.0F;
      int var21;
      zot var22;
      float[] var23;
      if (!var19 || var25 < 0 || var24 < 0 || !var7.c().isTextWrapped() && var7.c().getVerticalAlignment() != 6 && var7.c().getHorizontalAlignment() != 6 && var7.c().getRotationAngle() != 255) {
         for(var21 = 0; var21 < var1.size(); ++var21) {
            var22 = (zot)var1.get(var21);
            if (var22.a != null && var22.a.length() > 0 || var7.a) {
               if (var22.b == null) {
                  var22.b = var10;
               }

               var23 = new float[]{var20};
               this.a(var22, var23);
               var20 = var23[0];
            }
         }

         com.aspose.cells.b.a.a.ze.a(var1, 0, var1.size());
      } else {
         for(var21 = 0; var21 < var24; ++var21) {
            var22 = (zot)var1.get(0);
            if (var22.a != null && var22.a.length() > 0) {
               var23 = new float[]{var20};
               this.a(var22, var23);
               var20 = var23[0];
            }

            var1.remove(0);
         }

         zot var26 = (zot)var1.get(0);
         if (var26.a != null && var26.a.length() > 0) {
            var22 = new zot();
            if (var25 == Integer.MAX_VALUE) {
               var26.a = com.aspose.cells.b.a.zv.a(var26.a);
               var23 = new float[]{var20};
               this.a(var26, var23);
               var20 = var23[0];
               var1.remove(0);
            } else {
               var22.a = var26.a.substring(0, 0 + var25);
               var26.a = var26.a.substring(var25);
               var26.a = com.aspose.cells.b.a.zv.b(var26.a);
               var22.b = var26.b;
               var22.a = com.aspose.cells.b.a.zv.a(var22.a);
               if (var26.a.length() == 0) {
                  var1.remove(var26);
               }

               if (var22.a.length() != 0) {
                  var23 = new float[]{var20};
                  this.a(var22, var23);
                  var20 = var23[0];
               }
            }
         } else {
            var1.remove(0);
         }
      }

      this.d = this.g.c() * 72.0F / j * (float)this.m[1];
      this.c = var20;
      if (this.a.size() == 0 && !var3[0] && var19 && !var14) {
         this.d = 0.0F;
      }

      this.i = var3[0];
   }

   public static int a(String var0, float var1, int var2) throws Exception {
      byte var3 = 96;
      int var4 = (int)((var1 * 20.0F * (float)var3 + 720.0F) / 1440.0F);
      var4 = ~var4 + 1;
      int[] var5 = new int[10];
      com.aspose.cells.a.d.zfq var6 = com.aspose.cells.a.d.zfs.b(var0, var2, false);

      int var7;
      for(var7 = 48; var7 < 58; ++var7) {
         com.aspose.cells.a.d.zah var8 = var6.a(Math.abs(var4), (char)var7, (int)var1);
         var5[var7 - 48] = var8.i;
      }

      var7 = 0;
      boolean var12 = false;
      boolean var9 = false;
      int var14 = var5[0];

      int var10;
      for(var10 = 0; var10 < 10; ++var10) {
         int var13 = var5[var10];
         var7 += var13;
         if (var14 < var13) {
            var14 = var13;
         }
      }

      var10 = (var7 + 9) / 10;
      if (var14 < var10) {
         ;
      }

      int var11 = (var10 + 3) / 4;
      return (int)((double)((float)var11 * j / k) + 0.5D);
   }

   private boolean a(Font var1, float var2, ArrayList var3, boolean var4, boolean[] var5, float var6, int var7, boolean var8, int[] var9, int[] var10, com.aspose.cells.b.a.b.zt[] var11, float[] var12) throws Exception {
      float var13 = 0.0F;
      float var14 = 0.0F;
      int var15 = -1;
      int var16 = -1;
      int var17 = -1;
      int var18 = -1;
      float var19 = 0.0F;
      var10[0] = -1;
      var9[0] = -1;
      var11[0] = new com.aspose.cells.b.a.b.zt();
      var12[0] = 0.0F;
      float var20 = 0.0F;
      float var21 = 0.0F;
      int var22 = 1;
      int var23 = 1;
      float var24 = 0.0F;
      if (var3.size() > 0) {
         zot var25 = (zot)var3.get(0);
         if (var25.b == null) {
            var25.b = var1;
         }

         var20 = this.a(var25.b.getDoubleSize(), this.l);
         var22 = a(var25.b.getName(), var20, var25.b.m());
         var23 = a(var25.b.getName(), var20, var25.b.m()) + 1;
      }

      for(int var31 = 0; var31 < var3.size(); ++var31) {
         zot var26 = (zot)var3.get(var31);
         if (!var8 && var31 == 0 && !var4 && !var5[0]) {
            var26.a = com.aspose.cells.b.a.zv.b(var26.a);
         }

         var5[0] = false;
         ++var9[0];
         if (var26.b == null) {
            var26.b = var1;
         }

         com.aspose.cells.a.d.zfq var27 = com.aspose.cells.a.d.zfs.b(var26.b.getName(), var26.b.m(), false);
         var20 = this.a(var26.b.getDoubleSize(), this.l);
         var21 = (float)com.aspose.cells.a.d.zfq.a(var26.b.getName(), this.a(var26.b.getDoubleSize(), 1.0F), "|", var26.b.m()).c();
         if (var14 < var21) {
            var14 = var21;
         }

         if (var26.d == 16) {
            var5[0] = true;
            if (var18 >= 0 && var18 == var15) {
               var9[0] = var17;
               var10[0] = var16 + 1;
               var11[0].a(var19);
               var11[0].b(var14);
               var3.remove(var31);
            } else {
               var11[0].a(1.0F);
               var11[0].b(var14);
               var10[0] = 0;
            }

            return true;
         }

         var26.a = com.aspose.cells.b.a.zv.a(var26.a, "\u0000", "");

         for(int var28 = 0; var28 < var26.a.length(); ++var28) {
            ++var15;
            char var29 = var26.a.charAt(var28);
            float var30 = this.a(var27, var29, var20);
            if (var26.b.isSubscript() || var26.b.isSuperscript()) {
               var30 = this.a(var27, var29, var20 * zgd.b);
            }

            if (!var8 && (var29 == '-' || var29 == ' ') && var18 < var15 && var28 < var26.a.length()) {
               var17 = var9[0];
               var16 = var28;
               var19 = var13;
               var18 = var15;
            }

            if (var7 != 0) {
               if (var7 != 90 && var7 != -90) {
                  var24 = (float)Math.abs((double)var6 / Math.sin((double)((float)var7 / 180.0F * 3.14F)) - (double)var14 / Math.tan((double)((float)var7 / 180.0F * 3.14F)));
               } else {
                  var24 = var6;
               }
            } else {
               var24 = var2;
            }

            if (var13 + var30 > var24 - (float)var22 - (float)var23 || var8 && var15 > 0) {
               if (var28 == 0) {
                  --var9[0];
                  if (var26.b.isSubscript() || var26.b.isSuperscript()) {
                     --var9[0];
                  }

                  if (var9[0] < 0) {
                     var10[0] = 0;
                     var11[0].a(var13);
                     var11[0].b(var14);
                     return false;
                  }

                  var10[0] = ((zot)var3.get(var9[0])).a.length();
                  var11[0].a(var13);
                  var11[0].b(var14);
               } else if (var18 >= 0) {
                  var9[0] = var17;
                  var10[0] = var16 + 1;
                  var11[0].a(var19);
                  var11[0].b(var14);
               } else if (var9[0] > 0 && var18 < 0) {
                  --var9[0];
                  var10[0] = Integer.MAX_VALUE;
                  var11[0].a(var13);
                  var11[0].b(var14);
               } else {
                  if (var9[0] >= 0) {
                     var10[0] = var28;
                  }

                  var11[0].a(var13);
                  var11[0].b(var14);
               }

               return true;
            }

            var13 += var30;
         }
      }

      var11[0].a(var13);
      var11[0].b(var14);
      return false;
   }

   private void a(zot var1, float[] var2) throws Exception {
      float var3 = 0.0F;
      com.aspose.cells.a.d.zfq var4 = com.aspose.cells.a.d.zfs.b(var1.b.getName(), var1.b.m(), false);
      float var5 = this.a(var1.b.getDoubleSize(), this.l);
      float var6 = this.a(var4, var5, var1);
      if (this.f < var6) {
         this.f = var6;
      }

      if (!var1.b.isSuperscript() && !var1.b.isSubscript()) {
         var3 = this.a(var4, var1.a, var5);
      } else {
         var3 = this.a(var4, var1.a, var5 * zgd.b);
      }

      com.aspose.cells.b.a.a.ze.a(this.a, (Object)(new zbch(var1, var2[0], var3)));
      var2[0] += var3;
   }

   private float a(com.aspose.cells.a.d.zfq var1, float var2, zot var3) {
      float var4 = var1.b(var2);
      var4 = zbod.a(var4, var3.b.getName());
      return var4;
   }

   protected abstract float a(double var1, float var3);

   protected abstract float a(com.aspose.cells.a.d.zfq var1, char var2, float var3) throws Exception;

   protected abstract float a(com.aspose.cells.a.d.zfq var1, String var2, float var3) throws Exception;
}
